package com.lovo.exception;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Player extends Role{

    @Override
    public void generate() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入四位不重复数字：");
        int [] numbers = getNumbers();
        for(int i = 0;i < 4;i++){
            try{
                System.out.println("第"+(i+1)+"位：");
                numbers[i] = sc.nextInt();
                for(int j = 0;j < i;j++){
                    if(numbers[i] == numbers[j]){
                        System.out.println("已重复，请重新输入");
                        i--;
                        break;
                    }
                }
            }catch(InputMismatchException e){
                System.out.println("输入有误，请重新输入");
                sc.next();
                i--;
            }


        }

    }
}
